﻿@model IEnumerable<QRCode2.Models.HomeForSale>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @if ((User.IsInRole("Administrator")) || (User.IsInRole("RealEstateAgent")))
    {
        @Html.ActionLink("Create New", "Create")
    }
</p>
<table>
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Description)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Address)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.DaysOnMarket)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Heating)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.YearBuilt)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.AskingPrice)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Active)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Description)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Address)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.DaysOnMarket)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Heating)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.YearBuilt)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.AskingPrice)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Active)
        </td>
        <td>
            @if (User.IsInRole("HomeBuyer"))
            {
                @Html.ActionLink("Details", "Details", new { id=item.ID }) 
            }

            @if ((User.IsInRole("Administrator")) || (User.IsInRole("RealEstateAgent")))
            {
                @Html.ActionLink("Edit", "Edit", new { id=item.ID }) 
           
            }
        </td>
    </tr>
}

</table>
